<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="名称" prop="warehouseName">
        <el-input
          v-model="queryParams.warehouseName"
          placeholder="请输入名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属省份" prop="province">
        <el-select v-model="queryParams.province" clearable placeholder="请选择所属省份" @change="handleProvince($event)">
          <el-option v-for="(val,key) in provinceData" :key="key" :label="val.value" :value="val.pid">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所属城市" prop="city">
        <el-select v-model="queryParams.city" clearable placeholder="请选择所属城市" @change="handleCity($event)">
          <el-option v-for="(val,key) in cityData" :key="key" :label="val.value" :value="val.pid">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所属区县" prop="area">
        <el-select v-model="queryParams.area" clearable placeholder="请选择所属区县" @change="handleArea($event)">
          <el-option v-for="(val,key) in areaData" :key="key" :label="val.value" :value="val.pid">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="联系人" prop="contacts">
        <el-input
          v-model="queryParams.contacts"
          placeholder="请输入联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系电话" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入联系电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:warehouse:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:warehouse:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:warehouse:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:warehouse:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="warehouseList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="仓库ID" align="center" prop="warehouseId"/>
      <el-table-column label="编码" align="center" prop="warehouseCode"/>
      <el-table-column label="名称" align="center" prop="warehouseName"/>
      <el-table-column label="仓库库容" align="center" prop="capacity"/>
      <el-table-column label="地址" align="center" prop="warehouseAddress"/>
      <el-table-column label="邮编" align="center" prop="postcode"/>
      <el-table-column label="所属省份" align="center" prop="province"/>
      <el-table-column label="所属城市" align="center" prop="city"/>
      <el-table-column label="所属区县" align="center" prop="area"/>
      <el-table-column label="联系人" align="center" prop="contacts"/>
      <el-table-column label="联系电话" align="center" prop="phone"/>
      <el-table-column label="联系邮箱" align="center" prop="email"/>
      <el-table-column label="类型" align="center" prop="type">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_warehouse_type" :value="scope.row.type"/>
        </template>
      </el-table-column>
      <el-table-column label="纬度" align="center" prop="latitude"/>
      <el-table-column label="经度" align="center" prop="longitude"/>
      <el-table-column label="剩余库容" align="center" prop="residueCapacity"/>
      <el-table-column label="具备充电桩" align="center" prop="hasCharge"/>
      <el-table-column label="仓库租赁期限" align="center" prop="leaseTerm"/>
      <el-table-column label="备注" align="center" prop="remark"/>
      <el-table-column label="作业开始时间" align="center" prop="jobStartTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jobStartTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="作业结束时间" align="center" prop="jobEndTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jobEndTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="160">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleLook(scope.row)"
            v-hasPermi="['system:warehouse:edit']"
          >查看
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:warehouse:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:warehouse:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改基础信息-仓库对话框 -->
    <el-dialog :title="title" :visible.sync="open" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="编码" prop="warehouseCode">
                <el-input v-model="form.warehouseCode" placeholder="请输入编码"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="名称" prop="warehouseName">
                <el-input v-model="form.warehouseName" placeholder="请输入名称"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="地址" prop="warehouseAddress">
                <el-input v-model="form.warehouseAddress" placeholder="请输入地址"/>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="邮编" prop="postcode">
                <el-input v-model="form.postcode" placeholder="请输入邮编"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="类型" prop="type">
                <el-select v-model="form.type" placeholder="请输入订单状态" clearable width="140px">
                  <el-option
                    v-for="dict in dict.type.sys_warehouse_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="所属省份" prop="province">
                <el-select v-model="form.province" clearable placeholder="请选择所属省份" @change="handleProvince($event)"
                           style="width: 140px"
                >
                  <el-option v-for="(val,key) in provinceData" :key="key" :label="val.value" :value="val.pid">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="所属城市" prop="city">
                <el-select v-model="form.city" clearable placeholder="请选择所属城市" @change="handleCity($event)"
                           style="width: 140px"
                >
                  <el-option v-for="(val,key) in cityData" :key="key" :label="val.value" :value="val.pid">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="所属区县" prop="area">
                <el-select v-model="form.area" clearable placeholder="请选择所属区县" @change="handleArea($event)"
                           style="width: 140px"
                >
                  <el-option v-for="(val,key) in areaData" :key="key" :label="val.value" :value="val.pid">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="联系人" prop="contacts">
                <el-input v-model="form.contacts" placeholder="请输入联系人"/>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="联系电话" prop="phone">
                <el-input v-model="form.phone" placeholder="请输入联系电话"
                          oninput="value=value.replace(/[^\d]/g,'');if(value.length > 11)value = value.slice(0, 11)"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="联系邮箱" prop="email">
                <el-input v-model="form.email" placeholder="请输入联系邮箱"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="仓库库容" prop="capacity">
                <el-input v-model="form.capacity" placeholder="请输入仓库库容"/>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="仓库租赁期限" prop="leaseTerm">
                <el-input v-model="form.leaseTerm" placeholder="请输入仓库租赁期限"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="纬度" prop="latitude">
                <el-input v-model="form.latitude" placeholder="请输入纬度"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="经度" prop="longitude">
                <el-input v-model="form.longitude" placeholder="请输入经度"/>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
                <el-form-item label="具备充电桩" prop="hasCharge">
                  <el-select
                    v-model=" form.hasCharge"
                    placeholder="请选择具备充电桩"
                    clearable
                    @keyup.enter.native="handleQuery"
                  >
                    <el-option v-for="(item,index) in isCharge" :key="index" :label="item"
                               :value="item"
                    ></el-option>
                  </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="作业开始时间" prop="jobStartTime">
                <el-date-picker clearable
                                v-model="form.jobStartTime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="请选择作业开始时间"
                                style="width: 140px"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="作业结束时间" prop="jobEndTime">
                <el-date-picker clearable
                                v-model="form.jobEndTime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="请选择作业结束时间"
                                style="width: 140px"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
            </el-col>
            <el-col :span="8">
              <el-form-item label="备注" prop="remark">
                <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
            </el-col>
          </el-col>
        </el-row>
      </el-form>
      <el-table
        :data="locations"
        size="mini"
        border
        highlight-current-row
        style="width: 100%"
        :header-cell-style="{background:'#f1f1f1'}"
      >
        <el-table-column label="库区" align="center">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.area "
              placeholder="请输入库区"
              clearable
            />
          </template>
        </el-table-column>
        <el-table-column label="库位" align="center">
          <template slot-scope="scope">
            <el-input
              placeholder="请输入库位"
              v-model="scope.row.place"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right">
          <template slot-scope="scope">
            <span class="spanBtn" @click="placeDelete(scope.$index)" style="color: #00afff">删除</span>
          </template>
        </el-table-column>
      </el-table>
      <div class="add-table" @click="addPlace" style="margin-bottom: 20px">添加</div>
      <div slot="footer" class="dialog-footer" style="text-align: center;">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--    查看  的弹出框-->
    <el-dialog :title="titleLook" :visible.sync="openLook" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px" :disabled="disabled">
        <el-row>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="编码" prop="warehouseCode">
                <el-input v-model="form.warehouseCode" placeholder="请输入编码"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="名称" prop="warehouseName">
                <el-input v-model="form.warehouseName" placeholder="请输入名称"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="地址" prop="warehouseAddress">
                <el-input v-model="form.warehouseAddress" placeholder="请输入地址"/>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="邮编" prop="postcode">
                <el-input v-model="form.postcode" placeholder="请输入邮编"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="类型" prop="type">
                <el-select v-model="form.type" placeholder="请输入订单状态" clearable width="140px">
                  <el-option
                    v-for="dict in dict.type.sys_warehouse_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="所属省份" prop="province">
                <el-select v-model="form.province" clearable placeholder="请选择所属省份" @change="handleProvince($event)"
                           style="width: 140px"
                >
                  <el-option v-for="(val,key) in provinceData" :key="key" :label="val.value" :value="val.pid">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="所属城市" prop="city">
                <el-select v-model="form.city" clearable placeholder="请选择所属城市" @change="handleCity($event)"
                           style="width: 140px"
                >
                  <el-option v-for="(val,key) in cityData" :key="key" :label="val.value" :value="val.pid">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="所属区县" prop="area">
                <el-select v-model="form.area" clearable placeholder="请选择所属区县" @change="handleArea($event)"
                           style="width: 140px"
                >
                  <el-option v-for="(val,key) in areaData" :key="key" :label="val.value" :value="val.pid">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="联系人" prop="contacts">
                <el-input v-model="form.contacts" placeholder="请输入联系人"/>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="联系电话" prop="phone">
                <el-input v-model="form.phone" placeholder="请输入联系电话"
                          oninput="value=value.replace(/[^\d]/g,'');if(value.length > 11)value = value.slice(0, 11)"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="联系邮箱" prop="email">
                <el-input v-model="form.email" placeholder="请输入联系邮箱"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="仓库库容" prop="capacity">
                <el-input v-model="form.capacity" placeholder="请输入仓库库容"/>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="仓库租赁期限" prop="leaseTerm">
                <el-input v-model="form.leaseTerm" placeholder="请输入仓库租赁期限"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="纬度" prop="latitude">
                <el-input v-model="form.latitude" placeholder="请输入纬度"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="经度" prop="longitude">
                <el-input v-model="form.longitude" placeholder="请输入经度"/>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
              <el-form-item label="具备充电桩" prop="hasCharge">
                <el-select
                  v-model=" form.hasCharge"
                  placeholder="请选择具备充电桩"
                  clearable
                  @keyup.enter.native="handleQuery"
                >
                  <el-option v-for="(item,index) in isCharge" :key="index" :label="item"
                             :value="item"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="作业开始时间" prop="jobStartTime">
                <el-date-picker clearable
                                v-model="form.jobStartTime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="请选择作业开始时间"
                                style="width: 140px"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="作业结束时间" prop="jobEndTime">
                <el-date-picker clearable
                                v-model="form.jobEndTime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="请选择作业结束时间"
                                style="width: 140px"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="8">
            </el-col>
            <el-col :span="8">
              <el-form-item label="备注" prop="remark">
                <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
            </el-col>
          </el-col>
        </el-row>
      </el-form>
      <el-table
        :data="locations"
        size="mini"
        border
        highlight-current-row
        style="width: 100%"
        :header-cell-style="{background:'#f1f1f1'}"
      >
          <el-table-column label="库区" align="center">
          <template slot-scope="scope">
            {{ scope.row.area }}
          </template>
        </el-table-column>
        <el-table-column label="库位" align="center">
          <template slot-scope="scope">
            {{ scope.row.place }}
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer" style="text-align: center;">
        <el-button @click="backTo">返回</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listWarehouse, getWarehouse, delWarehouse, addWarehouse, updateWarehouse } from '@/api/system/warehouse'
import { DistrictData } from '@/api/system/district'

export default {
  name: 'Warehouse',
  dicts: ['sys_warehouse_type'],
  data() {
    return {
      disabled:true,
      //库位列表数据
      locations: [{
        area: null,
        place: null
      }],
      //全部省份
      provinceData: [],
      cityData: [],
      areaData: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 基础信息-仓库表格数据
      warehouseList: [],
      // 弹出层标题
      titleLook: '',
      // 是否显示弹出层
      openLook: false,
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        warehouseCode: null,
        warehouseName: null,
        warehouseAddress: null,
        postcode: null,
        province: null,
        city: null,
        area: null,
        contacts: null,
        phone: null,
        email: null,
        type: null,
        latitude: null,
        longitude: null,
        hasCharge: null,
        jobStartTime: null,
        jobEndTime: null,
        capacity: null,
        leaseTerm: null
      },
      isCharge:['是','否'],
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    }
  },
  created() {
    this.getList()
    this.getProvinceData()
  },
  methods: {
    backTo(){
      this.openLook = false;
    },
    //
    handleLook(row) {
      this.reset()
      const warehouseId = row.warehouseId || this.ids
      getWarehouse(warehouseId).then(response => {
        this.form = response.data
        this.locations =response.data.locations
        this.openLook = true
        this.titleLook = '查看基础信息-仓库'
      })

    },
    //新增列 操作
    addPlace() {
      this.locations.push(
        {
          area: null,
          place: null
        }
      )
    },
    placeDelete(index) {
      this.locations.splice(index, 1)
    },
    // 选中地区
    handleArea(e) {
      let obj = {}
      obj = this.areaData.find((item) => {//这里的userList就是上面遍历的数据源
        if (item.pid === e) {
          return item
        }
      })
      if (this.open == true) {
        this.form.area = obj.value
      } else {
        this.queryParams.area = obj.value
      }

    },
    //选中城市
    handleCity(e) {
      let obj = {}
      obj = this.cityData.find((item) => {//这里的userList就是上面遍历的数据源
        if (item.pid === e) {
          return item
        }
      })
      if (this.open == true) {
        this.form.city = obj.value
      } else {
        this.queryParams.city = obj.value
      }
      DistrictData(e).then(response => {
        response.data.map((item) => {
          this.areaData.push({ value: item.districtName, pid: item.districtId })
        })
      })
      this.queryParams.area = ''
      this.form.area = ''
    },
    //选中省份
    handleProvince(e) {
      let obj = {}
      obj = this.provinceData.find((item) => {//这里的userList就是上面遍历的数据源
        if (item.pid === e) {
          return item
        }
      })
      if (this.open == true) {
        this.form.province = obj.value
      } else {
        this.queryParams.province = obj.value
      }
      DistrictData(e).then(response => {
        response.data.map((item) => {
          this.cityData.push({ value: item.districtName, pid: item.districtId })
        })
      })
      this.queryParams.city = ''
      this.form.city = ''
      this.queryParams.area = ''
      this.form.area = ''
    },
    //获取省份数据
    getProvinceData() {
      DistrictData(0).then(response => {
        response.data.map((item) => {
          this.provinceData.push({ value: item.districtName, pid: item.districtId })
        })
      })
    },
    /** 查询基础信息-仓库列表 */
    getList() {
      this.loading = true
      listWarehouse(this.queryParams).then(response => {
        this.warehouseList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        warehouseId: null,
        warehouseCode: null,
        warehouseName: null,
        warehouseAddress: null,
        postcode: null,
        province: null,
        city: null,
        area: null,
        contacts: null,
        phone: null,
        email: null,
        type: null,
        latitude: null,
        longitude: null,
        hasCharge: null,
        jobStartTime: null,
        jobEndTime: null,
        capacity: null,
        leaseTerm: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.warehouseId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '添加基础信息-仓库'
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const warehouseId = row.warehouseId || this.ids
      getWarehouse(warehouseId).then(response => {
        this.form = response.data
        this.open = true
        this.title = '修改基础信息-仓库'
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.form.locations=this.locations
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.warehouseId != null) {
            updateWarehouse(this.form).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.open = false
              this.getList()
            })
          } else {
            addWarehouse(this.form).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const warehouseIds = row.warehouseId || this.ids
      this.$modal.confirm('是否确认删除基础信息-仓库编号为"' + warehouseIds + '"的数据项？').then(function() {
        return delWarehouse(warehouseIds)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/warehouse/export', {
        ...this.queryParams
      }, `warehouse_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
<style>
.el-date-editor.el-input, .el-date-editor.el-input__inner {
  width: 360px;
}

.add-table {
  width: 100%;
  height: 30px;
  border: 1px solid #dfe6ec;
  text-align: center;
  line-height: 30px;
  color: #00afff;
}

.el-dialog__body {
  padding: 5px 20px;
  color: #606266;
  font-size: 14px;
  word-break: break-all;
}

.el-dialog__footer {
  padding: 5px 20px;
  text-align: right;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
</style>
